<?php
require (dirname(__FILE__) . '/config/config.inc.php');
include 'classes/Facebook_login.php';
?>
<!DOCTYPE html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>AwesomePeople</title>
		<link rel="stylesheet" type="text/css"  href="css/style.css"/>
		<script type="text/javascript"  src="js/jquery.min.js"></script>
		<script type="text/javascript"  src="js/awesomepeople.js"></script>
		<script type="text/javascript"  src="js/init.js"></script>
	</head>
	<body>
		<div id="header">
			<div class="contentHeader">
				<a href="home" class="logo"></a>
				<div class="menu">
					<ul>
			<!-- 			<li>
							<form id="form" action="login.php" method="post">
							<label>User   :</label><input id="username" type="text" name="username" class="box"/>
							<label>Password  :</label><input id="password" type="password" name="password" class="box" />
							<input id="login_button" type="button" value=" Submit "/><br />
							<div id="message"></div>
							</form>
						</li> -->
						<li>
	<?php if ($user): ?>
	<img src="https://graph.facebook.com/<?php echo $user; ?>/picture">
       Bem vindo   <a href="<?php echo $user_profile['link'];?>"> <?php echo $user_profile['name']; ?>; </a> 

	  <a href="<?php echo $logoutUrl; ?>">Logout</a>
    <?php else: ?>
      <div>
     
    <?php endif ?>
					 <fb:login-button></fb:login-button>
<!--      <a href="<?php echo $loginUrl; ?>">Login with Facebook</a> -->
      </div>
					</li>	
					</ul>
					<div class="decoMenu"></div>
				</div>
			</div>
		</div>
		<div align="center">
			<div id="right_col">
				<div class="over-box"></div>
				<ul id="right_achievement_ul">
				</ul>
			</div>
		</div>
	<div id="fb-root"></div>
    <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId: '<?php echo _APP_ID_ ?>',
          cookie: true,
          xfbml: true,
          oauth: true
        });
        FB.Event.subscribe('auth.login', function(response) {
        	var data = new Object();
        	data.from = 'facebook';
        	data.password = response.userID;
             FB.api('/me', function(response) {
		       data.username = response.name;
		    });
           Awesomepeople.ajaxLogin('login.php', data );
        });
        FB.Event.subscribe('auth.logout', function(response) {
         console.log('out')
        });
      };
      (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol +
          '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
      }());
    </script>
	</body>
	
</html>
